package ${package.ServiceImpl};

import ${package.Entity}.${entity};
import ${package.Mapper}.${table.mapperName};
import ${package.Service}.${table.serviceName};
import ${superServiceImplClassPackage};
import com.cnpc.ds.utils.SqlUtil;
import com.cnpc.ds.utils.PageInfoUtil;
import org.springframework.stereotype.Service;
import com.cnpc.eisc.base.pojo.PageInfo;
import com.cnpc.eisc.base.pojo.Result;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;

/**
 * <p>
 * ${table.comment!} 服务实现类
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
@Service
<#if kotlin>
open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>(), ${table.serviceName} {

}
<#else>
public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}> implements ${table.serviceName} {

    @Override
    public PageInfo<${entity}> query(PageInfo<${entity}> page,String sort,Boolean isAsc,${entity} ${entity?uncap_first}){
        QueryWrapper<${entity}> queryWrapper = Wrappers.query(${entity?uncap_first});
        queryWrapper.orderBy(SqlUtil.sortFieldCheck(sort),isAsc,sort);
        Page<${entity}> wherePage = new Page<>(page.getPageNum(), page.getPageSize());
        Page<${entity}> entityPage = this.baseMapper.selectPage(wherePage, queryWrapper);
        return PageInfoUtil.getPageInfo(entityPage);
    }

    @Override
    public Integer add(${entity} ${entity?uncap_first}){
        this.saveOrUpdate(${entity?uncap_first});
        return 1;
    }

    @Override
    public Integer delete(List<String> ids){
        int res = baseMapper.deleteBatchIds(ids);
        return res;
    }

    @Override
    public ${entity} detail(String id){
        ${entity} entity = baseMapper.selectById(id);
        return entity;
    }
}
</#if>
